/**
 *@module Region
 *@desc 企业信息-区域
 *@author LiHongKun
 *@date 2018-08-10 11:36:58
 */
Ext.define('js.ranInsOfProQui.ranInsOfProQuishowPage', {
    extend: 'Ext.form.Panel',
    id:'ranInsOfProQuiAddPage',
    requires: ['js.Util', 'js.ctrl.Common'],
    controller: 'Common',
    config: {
        bodyPadding: '20 20 20 20',
        layout: {
            type: 'vbox',
            align: 'stretch'
        }
    },
    hidenField: {
        region_id: undefined
    },
    fieldDefaults: {
        labelWidth:120,
        flex:1,
        xtype: 'panel',
        allowBlank: false
    },
    initComponent: function () {

        Ext.QuickTips.init();
        Ext.form.Field.prototype.msgTarget = 'under';

        let ccxqjj=  {
                    xtype: 'textarea',
                    name: 'ccxqjj',
                    id: 'ccxqjj',
                    allowBlank: false,
                    msgTarget : 'qtip',
                    value:this.check_details,
                    readOnly:'true',
                    flex:2,
                    margin:'5 0 10 0',
                    labelSeparator: '',
                    fieldLabel: '抽查详情记录:',
                    colspan:2,
                };
        let sfxxxg = {
                    xtype: 'radiogroup',
                    fieldLabel: '是否下发整改',
                    id:'sfxxxg',
                    name:'sfxxxg',
                    margin:'15 0 0 0',
                    value:this.check_num?this.check_num:'1',
                    columns: 5,
                    vertical: true,
                    colspan:2,
                    items: [
                        { boxLabel: '是', inputValue: '1',margin:'2 0 0 0',id:'sfxxxgA', readOnly:'true',},
                        { boxLabel: '否', inputValue: '2',margin:'2 0 0 0',id:'sfxxxgB', readOnly:'true',}
                    ],
                    listeners :{
                        change:function(group,checked){
                            if(checked.sfxxxg == 2){
                                Ext.getCmp('rectification_date').setDisabled(true);
                                Ext.getCmp('bzA').setDisabled(true);
                                Ext.getCmp('zghfA').setDisabled(true);
                                Ext.getCmp('zgtzdA').setDisabled(true);
                                Ext.getCmp('zghfA').setValue('');
                                Ext.getCmp('bzA').setValue('');
                                Ext.getCmp('rectification_date').setValue('');
                                Ext.getCmp('zgtzdA').setValue('');
                            }else{
                                Ext.getCmp('zghfA').setDisabled(false);
                                Ext.getCmp('rectification_date').setDisabled(false);
                                Ext.getCmp('bzA').setDisabled(false);
                                Ext.getCmp('zgtzdA').setDisabled(false);
                            }
                        },
                        render:function (value) {
                            var bizVal = value.initialConfig.value;
                            if(bizVal == 2){
                                Ext.getCmp('sfxxxgB').setValue(true);
                            }else{
                                Ext.getCmp('sfxxxgA').setValue(true);
                            }
                        }
                    }
                };
        let zgwcsj={
            xtype: 'datefield',
            name: 'rectification_date',
            id: 'rectification_date',
            value:this.rectification_date,
            msgTarget : 'qtip',
            width: '50%',
            margin:'5 0 10 0',
            labelSeparator: '',
            fieldLabel: '整改完成日期:'
        };
        let zgtzdA={
            xtype: 'textfield',
            name: 'zgtzdA',
            id: 'zgtzdA',
            allowBlank: false,
            msgTarget : 'qtip',
            height:36,
            margin:'5 0 10 0',
            value:this.rectification_notice,
            readOnly:'true',
            labelSeparator: '',
            fieldLabel: '整改通知单:'
        };
        let zghfA={
            xtype: 'textfield',
            name: 'zghfA',
            id: 'zghfA',
            allowBlank: false,
            readOnly:'true',
            msgTarget : 'qtip',
            value:this.rectification_reply,
            height:36,
            margin:'5 0 10 0',
            labelSeparator: '',
            fieldLabel: '整改回复:'
        };
        let bzA= {
            xtype: 'textarea',
            name: 'bzA',
            id: 'bzA',
            allowBlank: false,
            value:this.remarks,
            msgTarget : 'qtip',
            readOnly:'true',
            flex:2,
            margin:'5 0 10 0',
            labelSeparator: '',
            fieldLabel: '备注:',
            colspan:2,
        };
        let items = [ccxqjj,sfxxxg,zgwcsj,zgtzdA,zghfA,bzA];

        this.items = items;

        this.callParent(arguments);
    },
    submit: function () {
        let form = this.getForm();
        let params = Ext.Object.merge({action_type: this.action_type}, this.hidenField);
        if (form.isValid()) {
            form.submit({
                params: params,
                success: this.success,
                failure: this.fail
            });
        }
    },
    success: function (response) {
        Ext.toast('保存成功');
    },
    fail: function (form, action) {
        Ext.toast(`<div style="font-size:28px;">保存失败，${action.failureType}，${action.result.message}</div>`);
    },
    afterrender: function (t, eop) {
        t.items.get(0).setValue(true);
    }
});